home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 1999 May / maximum-cd-1999-05.iso / Canvas 6 / DATA1.CAB / English_Tutorial_Files / Viewpage / ColDisjnt.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-11-04  |  2.0 KB  |  104 lines

  1. import java.awt.Graphics;
  2. import java.awt.Point;
  3. import java.awt.Polygon;
  4. import java.awt.Rectangle;
  5. import java.io.DataInputStream;
  6. import java.io.IOException;
  7.  
  8. final class ColDisjnt extends ColVecItm {
  9.    private Polygon[] m_poly;
  10.    private int[] m_pntsInSeg;
  11.  
  12.    public void draw(Graphics var1) {
  13.       int var3 = 0;
  14.  
  15.       for(int var2 = 0; var2 < super.m_numSegs; ++var2) {
  16.          this.m_poly[var2] = new Polygon();
  17.  
  18.          for(int var4 = 0; var4 < this.m_pntsInSeg[var2]; ++var4) {
  19.             this.m_poly[var2].addPoint((int)((super.m_ptArryX[var4 + var3] + 0.5F - super.m_colGraphicObj.m_xOrg) * super.m_colGraphicObj.m_mag), (int)((super.m_ptArryY[var4 + var3] + 0.5F - super.m_colGraphicObj.m_yOrg) * super.m_colGraphicObj.m_mag));
  20.          }
  21.  
  22.          var3 += this.m_pntsInSeg[var2];
  23.       }
  24.  
  25.       if (super.m_fillClr != null) {
  26.          if (super.m_colGraphicObj.m_overrideColor != null) {
  27.             var1.setColor(super.m_colGraphicObj.m_overrideColor);
  28.          } else {
  29.             var1.setColor(super.m_fillClr);
  30.          }
  31.  
  32.          for(int var5 = 0; var5 < super.m_numSegs; ++var5) {
  33.             var1.fillPolygon(this.m_poly[var5]);
  34.          }
  35.       }
  36.  
  37.       if (super.m_frameClr != null) {
  38.          if (super.m_colGraphicObj.m_overrideColor != null) {
  39.             var1.setColor(super.m_colGraphicObj.m_overrideColor);
  40.          } else {
  41.             var1.setColor(super.m_frameClr);
  42.          }
  43.  
  44.          for(int var6 = 0; var6 < super.m_numSegs; ++var6) {
  45.             var1.drawPolygon(this.m_poly[var6]);
  46.          }
  47.       }
  48.  
  49.    }
  50.  
  51.    public ColDisjnt(DataInputStream var1, int var2, int var3, ColGrph var4, Graphics var5) throws IOException {
  52.       super(var1, var3, var4);
  53.       int var7 = 0;
  54.       super.m_numSegs = var1.readInt();
  55.       this.m_pntsInSeg = new int[super.m_numSegs];
  56.       this.m_poly = new Polygon[super.m_numSegs];
  57.  
  58.       for(int var6 = 0; var6 < super.m_numSegs; ++var6) {
  59.          this.m_pntsInSeg[var6] = var1.readShort();
  60.          var7 += this.m_pntsInSeg[var6];
  61.       }
  62.  
  63.       super.m_ptArryX = new float[var7];
  64.       super.m_ptArryY = new float[var7];
  65.       var7 = 0;
  66.  
  67.       for(int var10 = 0; var10 < super.m_numSegs; ++var10) {
  68.          for(int var8 = 0; var8 < this.m_pntsInSeg[var10]; ++var8) {
  69.             super.m_ptArryX[var8 + var7] = (float)var1.readInt() / 65536.0F;
  70.             super.m_ptArryY[var8 + var7] = (float)var1.readInt() / 65536.0F;
  71.          }
  72.  
  73.          var7 += this.m_pntsInSeg[var10];
  74.       }
  75.  
  76.       int var14 = 0;
  77.  
  78.       for(int var11 = 0; var11 < super.m_numSegs; ++var11) {
  79.          this.m_poly[var11] = new Polygon();
  80.  
  81.          for(int var9 = 0; var9 < this.m_pntsInSeg[var11]; ++var9) {
  82.             this.m_poly[var11].addPoint((int)(super.m_ptArryX[var9 + var14] + 0.5F), (int)(super.m_ptArryY[var9 + var14] + 0.5F));
  83.          }
  84.  
  85.          var14 += this.m_pntsInSeg[var11];
  86.       }
  87.  
  88.       Rectangle var15 = new Rectangle(new Point(this.m_poly[0].xpoints[0], this.m_poly[0].ypoints[0]));
  89.  
  90.       for(int var12 = 0; var12 < super.m_numSegs; ++var12) {
  91.          var15.union(this.m_poly[var12].getBoundingBox());
  92.       }
  93.  
  94.       super.m_bounds.x = var15.x;
  95.       super.m_bounds.y = var15.y;
  96.       super.m_bounds.width = var15.width;
  97.       super.m_bounds.height = var15.height;
  98.    }
  99.  
  100.    public Rectangle getBounds() {
  101.       return super.m_bounds;
  102.    }
  103. }
  104.